#include "atomic_0826_data_access_service.h"


// 模拟实现：仅进行简单的数据填充和状态设置
int getNavData(NavDataInput* navInput, NavDataOutput* navOutput)
{
    // 检查输入输出指针有效性
    if (navInput == nullptr || navOutput == nullptr)
    {
        return ATOMIC_SERVICE_FAIL; // 无效指针返回错误
    }

    // 初始化输出结构体
    memset(navOutput, 0, sizeof(NavDataOutput));

    // 模拟数据有效性：假设至少有一个传感器数据有效
    navOutput->data_valid = 1;
    navOutput->return_type = 0; // 0表示成功

    // 模拟时间同步：取GPS时间作为基准
    navOutput->sync_time = navInput->gps_time;
    navOutput->time_offset = static_cast<float>(navInput->imu_time - navInput->gps_time);

    // 模拟有效传感器数量：假设GPS和IMU有效
    navOutput->sensor_count = 2;

    // 填充GPS数据（直接复制输入）
    navOutput->gps_time = navInput->gps_time;
    navOutput->gps_lat = navInput->gps_latitude;
    navOutput->gps_lon = navInput->gps_longitude;
    navOutput->gps_alt = navInput->gps_altitude;
    navOutput->gps_hdop = navInput->gps_hdop;

    // 填充IMU数据（直接复制输入）
    navOutput->imu_time = navInput->imu_time;
    navOutput->imu_acc_x = navInput->imu_acc_x;
    navOutput->imu_acc_y = navInput->imu_acc_y;
    navOutput->imu_acc_z = navInput->imu_acc_z;
    navOutput->imu_gyro_x = navInput->imu_gyro_x;
    navOutput->imu_gyro_y = navInput->imu_gyro_y;
    navOutput->imu_gyro_z = navInput->imu_gyro_z;

    // 模拟磁力计数据（输入中没有，填充固定值）
    navOutput->imu_mag_x = 45.2f;
    navOutput->imu_mag_y = 23.7f;
    navOutput->imu_mag_z = -18.3f;

    // 模拟校准参数（固定零偏值）
    navOutput->imu_acc_bias_x = 0.01f;
    navOutput->imu_acc_bias_y = -0.02f;
    navOutput->imu_acc_bias_z = 0.03f;
    navOutput->imu_gyro_bias_x = 0.001f;
    navOutput->imu_gyro_bias_y = -0.002f;
    navOutput->imu_gyro_bias_z = 0.001f;

    return ATOMIC_SERVICE_SUCCESS;
}
